{extend name="public:base"}
{block name="body"}
<div class="row">
    <div class="col-md-8">
        <h2>用户注册</h2>
        <form  id="login">
            <div class="form-group row">
                <label for="name" class="col-sm-2 col-form-label">用户名</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="name" placeholder="请输入用户名" name="name">
                </div>
            </div>
            <div class="form-group row">
                <label for="mobile" class="col-sm-2 col-form-label">电话</label>
                <div class="col-sm-10">
                    <input type="text"  class="form-control" id="mobile" placeholder="请输入手机号码" name="mobile">
                </div>
            </div>
            <div class="form-group row">
                <label for="email" class="col-sm-2 col-form-label">邮箱</label>
                <div class="col-sm-10">
                    <input type="text"  class="form-control" id="email" placeholder="请输邮箱" name="email">
                </div>
            </div>
            <div class="form-group row">
                <label for="password" class="col-sm-2 col-form-label">密码</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="password" placeholder="请输入密码" name="password">
                </div>
            </div>
            <div class="form-group row">
                <label for="password-confirm" class="col-sm-2 col-form-label">确认密码</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="password-confirm" placeholder="请输入密码" name="password_confirm">
                </div>
            </div>
            <div class="form-group row ">
                <label  class="col-sm-2 col-form-label"></label>
                <div class="col-sm-10">
                <button type="button" class="btn btn-primary mb-2" id="register">注册</button>
                </div>
            </div>


        </form>
    </div>
    <script>
        $(function () {
            $('#register').on('click',function () {
                $.ajax(
                    {
                        type:'post',
                        url:"{:url('index/user/insert')}",
                        data:$('#login').serialize(),
                        datatype:'json',
                        success:function (res) {
                            switch (res.status) {
                                case 1:
                                    alert(res.msg);
                                    window.location.href="{:url('index/index/index')}";
                                    break;
                                case 0:
                                case -1:
                                    alert(res.msg);
                                    break;
                            }
                        }
                    }
                )
            })
        })
    </script>
{/block}